<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>安装</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="tokyo-tyrant.requirements.html">需求</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="tokyo-tyrant.configuration.html">运行时配置</a></div>
 <div class="up"><a href="tokyo-tyrant.setup.html">安装／配置</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="tokyo-tyrant.installation" class="section">
 <h2 class="title">安装</h2>

 <p class="para">
  安装此 PECL 扩展相关的信息可在手册中标题为
<a href="install.pecl.html" class="link">PECL
扩展的安装</a>章节中找到。更多信息如新的发行版本、下载、源文件、
维护人员信息及变更日志等，都在此处：
  <a href="http://pecl.php.net/package/tokyo_tyrant" class="link external">&raquo;&nbsp;http://pecl.php.net/package/tokyo_tyrant</a>
 </p>

 <div class="section" id="tokyo-tyrant.configure-options">
  <h2 class="title">Configure options</h2>
  <ul class="simplelist">
   <li class="member"><em>--with-tokyo-tyrant[=DIR]</em> DIR is the prefix to the Tokyo Tyrant installation</li>
   <li class="member"><em>--with-tokyo-cabinet-dir[=DIR]</em> DIR is the prefix to the Tokyo Cabinet installation</li>
   <li class="member"><em>--disable-tokyo-tyrant-session</em> Disable Tokyo Tyrant session handler support</li>
  </ul>
 </div>

 <div class="section" id="tokyo-tyrant.enabling-the-extension">
  <h2 class="title">Enabling the extension</h2>
  <p class="para">
   The extension can be enabled by adding <em>extension=tokyo_tyrant.so</em> to the INI-configuration
  </p>
 </div>

 <div class="section" id="tokyo-tyrant.session-running">
  <h2 class="title">Running Tokyo Tyrant for the session handler</h2>
  <p class="para">
   <em>ttserver -port 2000 -ext /path/to/expire.lua -extpc expire 30.0 &#039;/tmp/sessions.tct#idx=ts:dec&#039;</em>
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    expire.lua is included in the tokyo_tyrant extension source distribution
   </span>
  </p></blockquote>
 </div>

 <div class="section" id="tokyo-tyrant.configuring-session-handler">
  <h2 class="title">Configuring session handler</h2>
  <p class="para">
    <ul class="simplelist">
     <li class="member">tokyo_tyrant.session_salt=&quot;randomlongstring&quot;</li>
     <li class="member">session.save_handler=tokyo_tyrant</li>
     <li class="member">session.save_path=&quot;tcp://hostname1:2000,tcp://hostname2:2000&quot;</li>
    </ul>
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    It is important to make sure that <a href="tokyo-tyrant.configuration.html#ini.tokyo-tyrant.session-salt" class="link">tokyo_tyrant.session_salt</a> matches on all servers.
   </span>
  </p></blockquote>
 </div>

 <div class="section" id="tokyo-tyrant.how-session-handler-works">
  <h2 class="title">How it works?</h2>
  <p class="para">
    The session handler creates a session id like the following:
    8b0e27a823fa4a6cf7246945b82c1d51-a5eadbbed1f2075952900628456bfd6830541629-0-5460
  </p>

  <p class="para">
   The parts from left to right:
  </p>
   
    <ul class="simplelist">
     <li class="member"><em>Session id</em> - Generated session id</li>
     <li class="member"><em>Checksum</em> - Checksum of session salt, session id, node id and primary key</li>
     <li class="member"><em>Node id</em> - The id of the node where the session maps to</li>
     <li class="member"><em>Primary key</em> - The primary key of the row where the session is stored</li>
    </ul>

   <p class="para">
    The checksum contains SHA1 sum of the node id, primary key, session id and the salt which is known only on the server side. This allows quick mapping of session id to node and primary key since there is no need to do an additional search. During session id regeneration only the parts 1 and 2 change but the mapping to the node and primary key stays constant.
  </p>
  <p class="para">
   In case some of the nodes fail <a href="tokyo-tyrant.configuration.html#ini.tokyo-tyrant.allow-failover" class="link">tokyo_tyrant.allow_failover</a>, <a href="tokyo-tyrant.configuration.html#ini.tokyo-tyrant.fail-threshold" class="link">tokyo_tyrant.fail_threshold</a> and <a href="tokyo-tyrant.configuration.html#ini.tokyo-tyrant.health-check-divisor" class="link">tokyo_tyrant.health_check_divisor</a> INI-settings control the behavior during failover. If failover is allowed the session handler will map the session to a healthy node and creates a new empty session.
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="tokyo-tyrant.requirements.html">需求</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="tokyo-tyrant.configuration.html">运行时配置</a></div>
 <div class="up"><a href="tokyo-tyrant.setup.html">安装／配置</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
